namespace Library
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    [ToolboxBitmap(typeof(AlarmList))]
    public class AlarmList : UserControl
    {
        private ColumnHeader columnHeader1;
        private ColumnHeader columnHeader2;
        private ColumnHeader columnHeader3;
        private ColumnHeader columnHeader4;
        private ColumnHeader columnHeader5;
        private IContainer components = null;
        private ListView listView1;

        public AlarmList()
        {
            this.InitializeComponent();
            base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
        }

        public void AddToList(string id, string name, string timestamp, string discribe, string stype, bool bAlarm)
        {
            int count;
            int num2;
            if (bAlarm)
            {
                count = this.listView1.Items.Count;
                for (num2 = 0; num2 < count; num2++)
                {
                    if (this.listView1.Items[num2].SubItems[0].Text.Equals(id))
                    {
                        return;
                    }
                }
                ListViewItem item = new ListViewItem();
                item.SubItems[0].Text = id;
                item.SubItems.Add(name);
                item.SubItems.Add(timestamp);
                item.SubItems.Add(discribe);
                item.SubItems.Add(stype);
                this.listView1.Items.Add(item);
            }
            else
            {
                count = this.listView1.Items.Count;
                for (num2 = 0; num2 < count; num2++)
                {
                    if (this.listView1.Items[num2].SubItems[0].Text.Equals(id))
                    {
                        this.listView1.Items.Remove(this.listView1.Items[num2]);
                        break;
                    }
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.listView1 = new System.Windows.Forms.ListView();
            this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
            this.SuspendLayout();
            // 
            // listView1
            // 
            this.listView1.BackColor = System.Drawing.SystemColors.Window;
            this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader1,
            this.columnHeader2,
            this.columnHeader3,
            this.columnHeader4,
            this.columnHeader5});
            this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.listView1.FullRowSelect = true;
            this.listView1.GridLines = true;
            this.listView1.Location = new System.Drawing.Point(0, 0);
            this.listView1.MultiSelect = false;
            this.listView1.Name = "listView1";
            this.listView1.Size = new System.Drawing.Size(378, 245);
            this.listView1.TabIndex = 0;
            this.listView1.UseCompatibleStateImageBehavior = false;
            this.listView1.View = System.Windows.Forms.View.Details;
            this.listView1.Resize += new System.EventHandler(this.listView1_Resize);
            // 
            // columnHeader1
            // 
            this.columnHeader1.Text = "ID";
            this.columnHeader1.Width = 76;
            // 
            // columnHeader2
            // 
            this.columnHeader2.Text = "名称";
            this.columnHeader2.Width = 77;
            // 
            // columnHeader3
            // 
            this.columnHeader3.Text = "时间";
            this.columnHeader3.Width = 78;
            // 
            // columnHeader4
            // 
            this.columnHeader4.Text = "描述";
            this.columnHeader4.Width = 81;
            // 
            // columnHeader5
            // 
            this.columnHeader5.Text = "类型";
            // 
            // AlarmList
            // 
            this.Controls.Add(this.listView1);
            this.Name = "AlarmList";
            this.Size = new System.Drawing.Size(378, 245);
            this.ResumeLayout(false);

        }

        private void listView1_Resize(object sender, EventArgs e)
        {
            this.listView1.ClientSize = base.ClientSize;
        }

        public Color AlarmBackColor
        {
            get
            {
                return this.listView1.BackColor;
            }
            set
            {
                this.listView1.BackColor = value;
                base.Invalidate();
            }
        }

        public Color AlarmForeColor
        {
            get
            {
                return this.listView1.ForeColor;
            }
            set
            {
                this.listView1.ForeColor = value;
                base.Invalidate();
            }
        }
    }
}

